﻿<UserControl x:Class="SoGame.Views.ReconnaissanceView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             xmlns:me="clr-namespace:SoGame.ViewModels" 
             d:DesignHeight="600" d:DesignWidth="600">
    <UserControl.Resources>
        <me:ReconnaissanceViewModel x:Key="viewModel" />
        <ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
            <WrapPanel Orientation="Horizontal" IsItemsHost="True"/>
        </ItemsPanelTemplate>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource viewModel}}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="0.65*"/>
                <RowDefinition Height="0.35*"/>
            </Grid.RowDefinitions>
            <Rectangle Grid.Row="1" Margin="-50,0">
                <Rectangle.Fill>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFD2D2D2" Offset="0.196"/>
                        <GradientStop Color="White" Offset="0.183"/>
                        <GradientStop Color="White" Offset="0.652"/>
                    </LinearGradientBrush>
                </Rectangle.Fill>
            </Rectangle>
            <Grid Grid.RowSpan="2" Margin="20,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid x:Name="Camera" Visibility="{Binding IsKinectReady}" MaxHeight="300" Grid.RowSpan="2" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="12">
                    <Image Source="{Binding KinectSource}" Visibility="{Binding CanDisplayKinectSource}" Stretch="UniformToFill" />
                    <!--Image Source="{Binding PlayerImage}" Visibility="{Binding CanDisplayNormalSource}"/-->
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Right">
                        <Button Content="UP" Click="Button_Click" VerticalAlignment="Bottom"/>
                        <Button Content="DOWN" Click="Button_Click_1" VerticalAlignment="Bottom"/>
                    </StackPanel>
                </Grid>
                <Image Grid.Column="1" Source="/SoGame;component/Assets/Images/AVATAR.png" Grid.RowSpan="2" VerticalAlignment="Top" Margin="0" Opacity="0.5" Visibility="{Binding UserIsReconize, ConverterParameter=false, Converter={StaticResource VisibilityConverter}}" />
                <Image Grid.Column="1" Source="/SoGame;component/Assets/Images/AVATAR.png" Grid.RowSpan="2" VerticalAlignment="Top" Margin="0" Visibility="{Binding UserIsReconize, Converter={StaticResource VisibilityConverter}}" />
                <StackPanel Grid.Column="2" Margin="12,0" >
                    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Style="{DynamicResource MetroHeader1}"><Run Language="fr-fr" Text="Faites face à la caméra !"/></TextBlock>
                    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Style="{DynamicResource MetroHeader2}" Visibility="{Binding UserIsReconize, ConverterParameter=false, Converter={StaticResource VisibilityConverter}}" Foreground="{DynamicResource CheckBoxBrush}"><Run Language="fr-fr" Text="Reconnaissance du joueur en cours..."/></TextBlock>
                    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Style="{DynamicResource MetroHeader2}" Visibility="{Binding UserIsReconize, Converter={StaticResource VisibilityConverter}}" Foreground="{DynamicResource CheckBoxBrush}"><Run Language="fr-fr" Text="Joueur(s) reconnu(s) ! "/></TextBlock>
                </StackPanel>
                <Grid x:Name="InfosUser" Grid.Column="2" Visibility="{Binding UserIsReconize, Converter={StaticResource VisibilityConverter}}" Grid.Row="1" Margin="12">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid x:Name="User" DataContext="{Binding CurrentPlayer}" Grid.ColumnSpan="2" d:LayoutOverrides="Width, Height" Visibility="Collapsed">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <StackPanel d:LayoutOverrides="Width, Height" Grid.ColumnSpan="1" Grid.Column="1" Margin="12,-5,0,0" Grid.RowSpan="2">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Name}" Style="{DynamicResource ItemTitle}"/>
                                <TextBlock Text="{Binding FirstName}" Style="{DynamicResource ItemTitle}" Margin="5,0,0,0"/>
                            </StackPanel>
                            <TextBlock Text="{Binding GamePlays.Count, StringFormat=\{0\} partie(s)}" Style="{DynamicResource MetroNormalText}" Foreground="{DynamicResource HighlightBrush}"/>
                            <TextBlock Text="{Binding Email}" Foreground="{DynamicResource LabelTextBrush}" VerticalAlignment="Top" Margin="0,0,-52,0" Style="{DynamicResource ItemDescription}"/>
                        </StackPanel>
                        <Grid Height="50" VerticalAlignment="Center" Width="50">
                            <Rectangle Grid.Column="0" Fill="{DynamicResource HighlightBrush}" HorizontalAlignment="Left" Stroke="{x:Null}" Width="50" Height="Auto" VerticalAlignment="Stretch"/>
                            <Image Source="{Binding Photo}" HorizontalAlignment="Stretch" Height="Auto" Width="Auto" VerticalAlignment="Stretch"/>
                        </Grid>
                    </Grid>
                    <ListBox ItemsSource="{Binding Players}" 
    					ScrollViewer.VerticalScrollBarVisibility="Visible" Grid.RowSpan="2" BorderBrush="{x:Null}" ItemContainerStyle="{DynamicResource ListBoxItemStyle1}" Grid.Column="1" Background="{x:Null}">
                        <ListBox.Resources>
                            <Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
                                <Setter Property="Background" Value="Transparent"/>
                                <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                                <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                                <Setter Property="Padding" Value="2,0,0,0"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                            <Grid Height="Auto">
                                                <VisualStateManager.VisualStateGroups>
                                                    <VisualStateGroup x:Name="CommonStates">
                                                        <VisualState x:Name="Normal"/>
                                                        <VisualState x:Name="MouseOver">
                                                            <Storyboard>
                                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="rectangle">
                                                                    <EasingDoubleKeyFrame KeyTime="0" Value="0.8"/>
                                                                </DoubleAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </VisualState>
                                                        <VisualState x:Name="Disabled"/>
                                                    </VisualStateGroup>
                                                    <VisualStateGroup x:Name="SelectionStates">
                                                        <VisualState x:Name="Unselected"/>
                                                        <VisualState x:Name="Selected">
                                                            <Storyboard>
                                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="rectangle">
                                                                    <EasingDoubleKeyFrame KeyTime="0" Value="0.8"/>
                                                                </DoubleAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </VisualState>
                                                        <VisualState x:Name="SelectedUnfocused"/>
                                                    </VisualStateGroup>
                                                    <VisualStateGroup x:Name="FocusStates">
                                                        <VisualState x:Name="Unfocused"/>
                                                        <VisualState x:Name="Focused">
                                                            <Storyboard>
                                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="rectangle">
                                                                    <EasingDoubleKeyFrame KeyTime="0" Value="0.8"/>
                                                                </DoubleAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                    <VisualStateGroup x:Name="ValidationStates">
                                                        <VisualState x:Name="Valid"/>
                                                        <VisualState x:Name="InvalidFocused"/>
                                                        <VisualState x:Name="InvalidUnfocused"/>
                                                    </VisualStateGroup>
                                                </VisualStateManager.VisualStateGroups>
                                                <Rectangle x:Name="rectangle" HorizontalAlignment="Stretch" Stroke="{x:Null}" Fill="{DynamicResource MetroMenuItemHover}" Opacity="0"/>
                                                <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true" d:LayoutOverrides="Width, Height">
                                                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="12,6"/>
                                                </Border>
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsSelected" Value="true">
                                                    <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                                                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
                                                </Trigger>
                                                <MultiTrigger>
                                                    <MultiTrigger.Conditions>
                                                        <Condition Property="IsSelected" Value="true"/>
                                                        <Condition Property="Selector.IsSelectionActive" Value="false"/>
                                                    </MultiTrigger.Conditions>
                                                    <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                                                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                                                </MultiTrigger>
                                                <Trigger Property="IsEnabled" Value="false">
                                                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ListBox.Resources>
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel Orientation="Horizontal" IsItemsHost="True" MaxWidth="400"/>
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <!--<Button Command="{Binding ElementName=LayoutRoot, Path=DataContext.ShowGamePlay}">-->
                                <Grid Background="Transparent">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <StackPanel d:LayoutOverrides="Width, Height" Grid.ColumnSpan="1" Grid.Column="1" Margin="12,-5,0,0" Grid.RowSpan="2">
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Name}" Style="{DynamicResource ItemTitle}"/>
                                            <TextBlock Text="{Binding FirstName}" Style="{DynamicResource ItemTitle}" Margin="5,0,0,0"/>
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Style="{DynamicResource MetroNormalText}" Foreground="{DynamicResource HighlightBrush}" Text="{Binding GamePlays.Count}"/>
                                            <TextBlock x:Name="txtParties" Style="{DynamicResource MetroNormalText}" Foreground="{DynamicResource HighlightBrush}">
                                               <Hyperlink Command="{Binding ElementName=LayoutRoot, Path=DataContext.ShowGamePlay}">
                                                    <!--<Run Text="{Binding ElementName=txtParties, Path=DataContext.GamePlays.Count, StringFormat=\{0\} partie(s)}" />-->
                                                    <Run Text=" parties"/>
                                                </Hyperlink>
                                            </TextBlock>
                                        </StackPanel>
                                        <!--<TextBlock Text="{Binding GamePlays.Count, StringFormat=\{0\} partie(s)}" Style="{DynamicResource MetroNormalText}" Foreground="{DynamicResource HighlightBrush}"/>-->
                                        <TextBlock Text="{Binding Email}" Foreground="{DynamicResource LabelTextBrush}" VerticalAlignment="Top" Margin="0,0,-52,0" Style="{DynamicResource ItemDescription}"/>
                                    </StackPanel>
                                    <Grid Height="50" VerticalAlignment="Center" Width="50">
                                        <Rectangle Grid.Column="0" Fill="{DynamicResource HighlightBrush}" HorizontalAlignment="Left" Stroke="{x:Null}" Width="50" Height="Auto" VerticalAlignment="Stretch"/>
                                        <Image Source="{Binding Photo}" HorizontalAlignment="Stretch" Height="Auto" Width="Auto" VerticalAlignment="Stretch"/>
                                    </Grid>
                                </Grid>
                                <!--</Button>-->
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </Grid>
            </Grid>
        </Grid>

    </Grid>
</UserControl>
